package io.renren.modules.bs.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.bs.entity.BsExtractDetailPatientEntity;
import io.renren.modules.bs.service.BsExtractDetailPatientService;
import io.renren.modules.bs.vo.ExtractDetailPatientVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-08-15 23:03:14
 */
@RestController
@RequestMapping("bs/extractDetailPatient")
public class BsExtractDetailPatientController {
    @Autowired
    private BsExtractDetailPatientService bsExtractDetailPatientService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bsExtractDetailPatientService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/listByDetailId")
    public R listByDetailId(Long detailId){
        List<ExtractDetailPatientVo> list = bsExtractDetailPatientService.listByDetailId(detailId);
        return R.ok().put("data", list);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{extractDetailPatientId}")
    public R info(@PathVariable("extractDetailPatientId") Long extractDetailPatientId){
		BsExtractDetailPatientEntity bsExtractDetailPatient = bsExtractDetailPatientService.getById(extractDetailPatientId);

        return R.ok().put("bsExtractDetailPatient", bsExtractDetailPatient);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BsExtractDetailPatientEntity bsExtractDetailPatient){
		bsExtractDetailPatientService.save(bsExtractDetailPatient);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BsExtractDetailPatientEntity bsExtractDetailPatient){
		bsExtractDetailPatientService.updateById(bsExtractDetailPatient);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] extractDetailPatientIds){
		bsExtractDetailPatientService.removeByIds(Arrays.asList(extractDetailPatientIds));

        return R.ok();
    }

}
